package com.xcw.util;

import com.alibaba.fastjson.JSON;
import com.xcw.test.CommonCheckResult;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;

import java.util.*;

/**
 * @author bhx
 * @Class ExcelUtilSpecial_5G
 * @date 2022/9/13 11:37
 * @Description 5G切片定制化导出表头设置
 */
public class ExcelUtilSpecial_5G {

    static String[] config_5G = {"0,1","0,2","0,3","0,4","0,5","0,6","0,7"};
    static String[] sheetNameArray = {"核查结果统计","一致的","设备少的","设备多的","差异的","冗余"};
    static String[] commonFiledName = {"业务名称","归局","网元","所在地区","设备厂商","检查项","设备名称","现网数据时间","现网数据","标准数据","一致的","设备少的","设备多的","差异的","冗余"};
    static String[] HW_AMF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","核查切片业务标识（LST PLMNNS:;）,SST,切片业务标识",",SD,",",状态,状态",",PLMN索引,PLMN索引","@,网络切片索引_PLMNNS,@","LST NFNS:;,网络切片索引_NFNS,@",",,备注",",,标识"};
    static String[] ZTE_AMF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","核查新增AmfSnssai配置（show AMFSNSSAI）,Snssai Name,切片业务标识","@,SST,切片业务标识","@,SD,@","核查新增Snssai统计对象配置（show PMSNSSAI）,SST,切片业务标识","@,SD,@","@,User Alias,切片业务标识",",,备注",",,标识"};
    static String[] HW_NSSF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","查询切片配置(LST CFGSNSSAI:;),切片服务类型,切片业务标识","@,切片细分标识,@","@,移动国家码,固定值","@,移动网号,固定值","@,激活状态,固定值","@,描述,切片业务标识","核查TAC配置（LST TACGROUPINNSSF:;）" +
            ",跟踪区域码分组名称,切片业务标识","@,TAC起始字符,TAI","@,TAC结束字符,TAI","核查AMF SET-ID配置（LST NSSFSETID:;）,切片服务类型,切片业务标识","@,切片细分标识,@","@,移动国家码,AMF SET-ID","@,移动网号,@","@,区域ID,@","@,NSSF集合标识,@","@,跟踪区域码分组名称,切片业务标识",",,备注",",,标识"};
    static String[] HW_SMF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","接入方式,@,@","查询切片(LST PLMNNS:;),切片业务类型,切片业务标识","@,切片细分标识,@","@,网络切片索引,网络切片索引", "查询NF支持的网络切片(LST NFNS:;),网络切片索引,网络切片索引","查询DNN (LST VPNINST:;),VPN实例名,V4地址池名称/V6地址池名称",
            "查询DNN (LST APN:;),APN名称,DNN名称", "@,VPN实例名,V4地址池名称/V6地址池名称","查询DNN (LST NSDNN:;),数据网络名称,DNN名称","查询DNN(LST APNPCCFUNC:;),APN名称,DNN名称","@,本地用户PCC功能,本地用户PCC功能", "@,漫游用户PCC功能,漫游用户PCC功能","@,拜访用户PCC功能,拜访用户PCC功能","查询UPF支持的网络切片（LST PNFNS:;),切片/服务类型,切片业务标识",
            "@,切片分类器,@","@,NF实例标识,NF实例标识", "查询N4地址(LST PNFPROFILE:;),NF实例标识,NF实例标识","@,IPV6ADDRESS1,UPF地址","查询UPF支持的DNN（LST PNFDNN:;),NF实例标识,NF实例标识","@,数据网络名称,DNN名称","查询将UserProfile Group绑定到APN(LST APNUSRPROFG:;,APN名称,DNN名称","@,用户模板组名称,用户模板组名称","查询鉴权和计费(LST APNRDSCLIENTIP:;),APN名称,DNN名称",
            "@,鉴权或计费,鉴权或计费", "@,接口名称,接口名称","查询DNN鉴权服务器(LST APNAUTHATTR:;),APN名称,DNN名称","查询APN绑定服务器组(LST APNRDSSVRGRP:;),APN名称,DNN名称","@,RADIUS Server Group名称,Radius模板","@,抄送Interim-Update Request,抄送Interim-Update Request","查询DNN静态地址((LST APNADDRESSATTR:;),APN名称,DNN名称", "查询DNN(LST APNRDSACCTCTRL:;),APN名称,DNN名称",
            "@,时间阈值（分）,时间阈值（分）","@,流量阈值（千字节）,流量阈值（千字节）","@,全部类型承载/PDP上下文均开启radius计费,全部类型承载/PDP上下文均开启radius计费","@,业务报文（通过3/4层规则配置）时触发计费请求消息,业务报文（通过3/4层规则配置）时触发计费请求消息","@,Acct请求超时是否去活用户,Acct请求超时是否去活用户","@,等待计费开始响应消息后才回应激活成功应答消息,等待计费开始响应消息后才回应激活成功应答消息",
            "查询本地地址池(LST ADDRPOOL:;),地址池名称,V4地址池名称/V6地址池名称","@,地址池类型,地址池类型","@,白名单检查开关,白名单检查开关","@,绑定VPN,绑定VPN","@,VPN实例名,V4地址池名称/V6地址池名称","查询APN与本地地址池绑定关系(LST POOLBINDAPN:;),APN名称,DNN名称","@,地址池名称,V4地址池名称/V6地址池名称","查询地址池里的地址段(LST SECTION:;),地址池名称,V4地址池名称/V6地址池名称","@,IP地址类型,IP地址类型",
            "@,IPv4起始地址,终端IPV4地址池","@,IPv4结束地址,@","@,IPv6起始地址,终端IPV6地址池","@,IPv6结束地址,@","查询地址池组名称（LST ADDRPOOLGRP:;）,地址池组名称,pgrp_DNN名称去.ZJ","@,地址池组类型,地址池组类型","@,IPv4基于地址池优先级分配地址算法,IPv4基于地址池优先级分配地址算法","@,IPv6基于地址池优先级分配地址算法,IPv6基于地址池优先级分配地址算法","查询地址池与地址池组绑定（LST POOLBINDGRP:;）,地址池组名称,pgrp_DNN名称去.ZJ",
            "@,地址池名称,V4地址池名称/V6地址池名称","查询终端V4地址池名称（LST ADDRUPGROUP:;）,UPF组名称,upf_grp_DNN名称去.ZJ","@,UPF组类型,UPF组类型","查询主、备UPF与UPF组绑定（LST UPBINDGRP:;）,UPF组名称,upf_grp_DNN名称去.ZJ","@,优先级,UPF地址","@,UPF实例标识,UPF实例标识","查询地址池组与UPF组绑定（LST POOLGRPMAP:;）,映射名称,mapping_DNN名称去.ZJ","@,地址池组名称,pgrp_DNN名称去.ZJ","@,UPF组名称,upf_grp_DNN名称去.ZJ",
            "查询指定终端DNS地址（（LST UEDNSBINDAPN:;,APN名称,DNN名称","@,是否指定终端DNS,是否指定终端DNS","@,IPv4主DNS服务器IP,指定终端DNS ipv4地址","@,IPv4备DNS服务器IP,@","@,IPv6主DNS服务器IP,指定终端DNS ipv6地址","@,IPv6备DNS服务器IP,@","共享式查询TAC（LST/UPAREABINDN2TAI:;/LST PNFSMFSERAREA:;/LST PNFPROFILE:;）,【UPF服务区名称绑定5GTAI范围起始值】-【UPF服务区名称绑定5GTAI范围结束值 】,TAC范围",
            "@,IPV6地址1,N4地址","LST BACKOFFTIME:;,APN名称,DNN名称","@,系统过载场景下Back-offTime开关,系统过载场景下Back-offTime开关","@,APN拥塞场景下Back-offTime开关,APN拥塞场景下Back-offTime开关","LST APNCHARGECTRL:;,APN名称,DNN名称","@,在线计费开关,在线计费开关","@,离线计费开关,离线计费开关","@,融合计费开关,融合计费开关",",,备注",",,标识"};
    static String[] ZTE_SMF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","接入方式,@,@","切片信息配置(SHOW ALLOWEDSNSSAI),SST,切片业务标识","@,SD(hex),@","新增SNSSAI配置(SHOW SNSSAICFG:;),S-NSSAI Name,切片业务标识","@,SST,切片业务标识","@,SD(hex),@","新增用户面S-NSSAI配置(SHOW UPSNSSAI:;),User Plane Name,UPF名称",
            "@,Slice Service Type,切片业务标识","@,Slice Differentiator,@","新增对S-NSSAI的性能统计配置(SHOW SNSSAI:;),S-NSSAI Name,切片业务标识","@,SST,切片业务标识","@,SD,@","查询APN/DNN所关联的真实APN/DNN（SHOW APNDNN:;）,APNDNN,DNN名称","@,Whether Real APNDNN,Whether Real APNDNN","@,Real APNDNN,DNN名称","新增网络切片内DNN配置（SHOW NSAPNDNN:;）,APN/DNN,DNN名称",
            "@,SST,切片业务标识","@,SD(hex),@","新增计费APN/DNN关联模板（SHOW ACCDNNTEMPLATE:;;）,APN/DNN,DNN名称","@,Converge Template Name,DNN名称","新增计费APN/DNN关联模板SHOW LOCALCC:;,APN/DNN,DNN名称","指定APN/DNN对应的profile配置（SHOW MAPAPNDNNPROFILE）,APN/DNN,DNN名称","@,Profile Name,DNN名称","主DNS配置SHOW PRIDNSADDR,APN/DNN,DNN名称","@,是否指定终端DNS,是否指定终端DNS",
            "@,Primary DNS Address,指定终端DNS地址","备DNS配置SHOW SECDNSADDR,APN/DNN,DNN名称","@,是否指定终端DNS,是否指定终端DNS","@,Secondary DNS Address,指定终端DNS地址","增加DNN下的PCC关联模板SHOW DNNPCCPROFILE,APN/DNN Name,DNN名称","@,PCC Function Profile Name,upg_”前缀不变+取自网络参数表的DNN名称","@,PCC Rule Profile Name,upg_”前缀不变+取自网络参数表的DNN名称",
            "@,PCF Dynamic Profile Name,DNN名称","配置APN/DNN计费属性SHOW ACCTRADIUSAPNMAP,APN/DNN,DNN名称","@,是否静态IP地址,是否静态IP地址","@,Radius profile name,Radius模板默认值","新增鉴权Radius profile 与APN映射关系配置AUTHRADIUSAPNMAP,APN/DNN,DNN名称","@,是否静态IP地址,是否静态IP地址","@,Radius profile name,Radius模板默认值","新增互操作配置SHOW INTERWORKING,DNN Name,DNN名称",
            "@,SST,切片业务标识","@,SD (hex),@","增加纯4G用户计费接口模式和PCC接口模式SHOW INTERFACEMODE,APN/DNN,DNN名称","@,Pure 4G User Charging Interface Mode,/","@,Pure 4G User PCC Interface Mode,/","新增网络实例号策略配置SHOW NETWORKINSTANCEPOLICY,Interface Type,Interface Type","@,APN/DNN,DNN名称","@,SST,切片业务标识","@,SD (hex),@","@,NETWORK INSTANCE,NETWORK INSTANCE",
            "PCC接入控制配置SHOW PCCACCESSMAP,APN/DNN,DNN名称","新增用户面组DNN配置SHOW UGROUPDNN,DNN,GW-U Group Name","@,DNN,DNN名称","新增网络实例配置SHOW NETWORKINSTANCE,Network Instance,UPF名-企业缩写-cmnet","新增IP地址池SHOW IPPOOL,IP Pool Name,V4地址池名称/V6地址池名称","@,是否静态IP地址,是否静态IP地址","@,IP Pool Attribute,IP Pool Attribute","@,Dynamic Route,Dynamic Route",
            "新增地址池与APN/DNN关联配置SHOW IPPOOLAPNDNNINFO,IP Pool Name,V4地址池名称/V6地址池名称","@,DNN,DNN名称","新增启用APN列表配置SHOW APNPMENLIST,APN,DNN名称","新增IPv4地址段SHOW IPSEGINFO,Segment Name,cmnetv4-UPF名称-企业缩写-seg","@,Start IP,终端IPV4地址池","@,End IP,@","@,Mask,@","@,Network Instance,UPF名-企业缩写-cmnet","@,UP Name,UPF名称","@,IP Pool Name,V4地址池名称",
            "新增IPv6地址段SHOW IPV6SEGINFO,Segment Name,cmnetv6-UPF名称-企业缩写-seg","@,ZX-V6PREFIX,终端IPV6地址池","@,ZX-V6PREFIXLENGTH,@","@,UP Name,UPF名称","@,IP Pool Name,V6地址池名称","IPM性能统计配置SHOW PMIPPSNSSAI,IP Pool Name,V4地址池名称/V6地址池名称","@,SNSSAI Name,切片业务标识","5G TAC查询方式SHOW UPSXINTERFACEIP,IPv6 Address,UPF地址","@,User Plane Name,UPF名称",
            "5G TAC查询方式SHOW UPTACNRGROUP,User Plane Name,UPF名称","@,TACNRGROUPNAME,/","5G TAC查询方式SHOW TACNRSECTION:TACGROUPNAME=\"xxx\",TACNRGROUPNAME,/","@,START(HEX),UPF所覆盖的TAI列表","@,END(HEX),@","4G TAC查询方式SHOW UPTACGROUP:;,User Plane Name,UPF名称","@,TACGROUPNAME,/","4G TAC查询方式SHOW TACSECTION:TACGROUPNAME=\"xxx\",TACGROUPNAME,/",
            "@,START(HEX),UPF所覆盖的TAI列表","@,END(HEX),@",",,备注",",,标识"};
    static String[] HW_UPF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","接入方式,@,@","查询切片(LST SNSSAI:;),切片/服务类型,切片业务标识","@,切片区分码,@","查询DNN（LST APN:; ）,APN名称,DNN名称","@,VPN实例名,VPN名称","@,IPv6 VPN实例名,VPN名称","查询APN单通检测(LST APNSGLPASS:;),APN名称,DNN名称","@,开关标识,开关标识","查询APN地址分配属性(LST APNADDRESSATTR:;),APN名称,DNN名称",
            "@,支持IPV4,支持IPV4","@,支持IPV6,支持IPV6","@,手机后路由,手机后路由","@,下行防欺诈,下行防欺诈","@,上行防欺诈,上行防欺诈","@,为双栈用户返回的地址类型,为双栈用户返回的地址类型","@,RA携带MTU选项开关,RA携带MTU选项开关","@,基于CP分配IP地址,基于CP分配IP地址","@,IPv6 RA消息路由生命周期(秒),IPv6 RA消息路由生命周期(秒)","@,分配单栈地址时返回的原因值,分配单栈地址时返回的原因值","@,主机地址,主机地址",
            "查询地址池名称LST POOL:;),地址池名称,V4地址池名称/V6地址池名称","@,IP地址类型,IP地址类型","@,检查地址合法性,检查地址合法性","@,绑定VPN,绑定VPN","@,IMS开关,IMS开关","@,地址池类型,地址池类型","@,VPN实例名,VPN_VPN名称","查询地址段配置（LST SECTION）,地址池名称,V4地址池名称/V6地址池名称","@,IP地址类型,IP地址类型","@,地址段的起始IPv4地址,终端IPV4地址池","@,地址段的终止IPv4地址,@","@,IPv6前缀起始地址,终端IPV6地址池",
            "@,IPv6前缀结束地址,@","查询地址池组(LST POOLGROUP:;）,地址池组名称,pgrp_DNNname去掉ZJ","@,IPV4基于地址池优先级分配地址算法,IPV4基于地址池优先级分配地址算法","@,IPV6基于地址池优先级分配地址算法,IPV6基于地址池优先级分配地址算法","查询绑定地址池到地址池组( LST POOLBINDGROUP:;）,地址池组名称,pgrp_DNNname去掉ZJ","@,地址池名称,V4地址池名称/V6地址池名称","@,地址池优先级,地址池优先级",
            "查询地址池组(LST POOLGRPMAP:;-APN名称),映射规则名称,map_DNN名称去掉.zj","@,APN名称,DNN名称","@,地址池组名称,pgrp_DNN名称去掉.zj","查询APN配置地址分配规则(LST APNIPALLOCRULE:),APN名称,DNN名称","@,IPv4分配属性,IPv4分配属性","@,IPv4第一级规则开关,IPv4第一级规则开关","@,IPv4第二级规则开关,IPv4第二级规则开关","@,IPv4第三级规则开关,IPv4第三级规则开关","@,IPv6分配属性,IPv6分配属性","@,IPv6第一级规则开关,IPv6第一级规则开关",
            "@,IPv6第二级规则开关,IPv6第二级规则开关","@,IPv6第三级规则开关,IPv6第三级规则开关","查询隧道和业务VPN（LST VPNINST:; ）,VPN实例名,VPN_VPN名称","查询隧道和业务VPN（LST L3VPNINST:;）,VPN实例名称,VPN_VPN名称","@,VPN实例描述,VPN_VPN名称","查询隧道和业务VPN（LST VPNINSTAF:;）,VPN实例名称,VPN_VPN名称","@,地址族类型,地址族类型","@,路由标识,核心网侧隧道源地址：VPN ID","查询VPN实例名和接口绑定（LST IPBINDVPN:）,VPN实例名称,VPN_VPN名称",
            "@,接口名,GRE TUNNEL标识","ipv4静态路由配置（LST SRROUTE:;),VPN实例名称,VPN_VPN名称","@,路由出接口名字,GRE TUNNEL标识","@,地址族,地址族","查询TCPMSS配置(LST TCPMSS:;),APN名称,DNN名称","@,IPv4 TCP报文长度（字节）,IPv4 TCP报文长度（字节）","@,IPv6 TCP报文长度（字节）,IPv6 TCP报文长度（字节）","查询备用UPF DNN(LST APNREDUNDUPSW:;),APN名称,DNN名称","@,APN支持IPV4上行转发功能,APN支持IPV4上行转发功能","@,APN支持IPV6上行转发功能,APN支持IPV6上行转发功能",
            "查询主用GRE隧道客户侧网络地址，建立GRE隧道（LST GRETUNNEL:;;）,隧道名称,GRE TUNNEL标识","@,隧道类型,隧道类型","@,目的IPv4地址,主用GRE隧道客户侧网络地址","@,使能Keepalive功能,使能Keepalive功能","@,Keepalive报文发送周期,Keepalive报文发送周期","@,不可达计数器参数,不可达计数器参数","@,使能端到端校验功能,使能端到端校验功能","封装GRE隧道，查询GRE TUNNEL标识（LST INTERFACE),接口名,GRE TUNNEL标识","@,接口最大传输单元,接口最大传输单元",
            "隧道核心网侧主用隧道接口地址（LST IFIPV4ADDRESS:;）,接口名,GRE TUNNEL标识","@,IPv4地址,隧道核心网侧主用隧道接口地址","@,IPv4地址掩码,IPv4地址掩码","@,IPv4地址类型,IPv4地址类型",",,备注",",,标识"};
    static String[] ZTE_UPF_5G_FiledName = {"数据来源,@,@","工单类型,@,@","归属省份,@,@","接入方式,@,@","核查NETWORKINSTANCE网络标识（show NETWORKINSTANCE）,网络实例名称,UPF名称+DNN名称缩写+cmnet","核查NETWORKINSTANCE关联ZXROSNG里的VRF名称和VRF ID（show  VPNINSTANCE）,网络实例,UPF名称+DNN名称缩写+cmnet","@,IPv4的VRF名称,DNN名称","@,IPv4的VPN ID,VPN ID","@,IPv6的VRF名称,DNN名称",
            "@,IPv6的VPN ID,VPN ID","核查新增APNDNN配置（SHOW APNDNN）,APNDNN,DNN名称","@,是否真实APNDNN,是否真实APNDNN","@,真实APNDNN,DNN名称","地址池（SHOW IPPOOL）,地址池名称,DNN名称","@,是否静态IP地址,是否静态IP地址","@,地址池属性,地址池属性","@,动态路由开关,动态路由开关","@,IP地址类型,IP地址类型","关联地址池（SHOW IPSEGINFO）,地址段名称,cmnetv4-UPF名称-DNN缩写-seg","@,起始地址,Ipv4终端地址池",
            "@,结束地址,@","@,掩码,@","@,网络实例名称,UPF名称+DNN名称缩写+cmnet","@,UP名称,UP名称","@,地址池名称,Ipv4地址池名称","关联地址池（SHOW IPV6SEGINFO）,地址段名称,cmnetv6-UPF名称-DNN缩写-seg","@,IPv6前缀,Ipv6终端地址池","@,IPv6前缀长度,@","@,UP名称,UPF名称","@,地址池名称,Ipv6地址池名称","地址池关联APN（SHOW IPPOOLAPNDNNINFO）,地址池名称,Ipv4地址池名称","@,DNN,DNN名称",
            "apn关联各自的配置模板（SHOW DNCFG）,APN/DNN,DNN名称","@,网络实例,UPF名称+DNN名称缩写+cmnet","@,S-NSSAI标识,切片业务标识","@,Slice Service Type,切片业务标识","@,Slice Differentiator,@","新增切片的的信息（SHOW SNSSAINAME）,邻接局名称,邻接局名称","@,S-NSSAI标识,切片业务标识","@,对象类型,对象类型","启用APN列表配置（SHOW APNPMENLIST）,APN,DNN名称",
            "GRE隧道接口地址（show ip vrf brief）,Name,DNN名称","@,Default RD,VPN ID：VPN ID","@,VRF ID,VPN ID","ip vrf 配置（show ip vrf brief）,Name,DNN名称","@,Default RD,VPN ID：VPN ID","@,VRF ID,VPN ID","GRE隧道（show running-config gre-tunnel/show running-config-interface gre_tunnelxxx）,interface gre_tunnel,VPN ID","@,description,DNN名称",
            "@, ip vrf forwarding,DNN名称","@,ip address,隧道核心网侧主用隧道接口地址","@,tunnel vrf,DNN名称","@,tunnel source ipv4,核心网侧隧道源地址","@,tunnel destination ipv4,主用GRE隧道客户侧网络地址","@,ip route vrf,DNN名称","@,gre_tunnel,VPN ID",",,备注",",,标识"};
    static Map<Integer,String[]> sheetNameMap = new LinkedHashMap<>();
    // 设置枚举 华为amf 5G
    static {
        sheetNameMap.put(0, commonFiledName);
        sheetNameMap.put(1, HW_AMF_5G_FiledName);
        sheetNameMap.put(2, ZTE_AMF_5G_FiledName);
        sheetNameMap.put(3, HW_NSSF_5G_FiledName);
        sheetNameMap.put(4, HW_SMF_5G_FiledName);
        sheetNameMap.put(5, ZTE_SMF_5G_FiledName);
        sheetNameMap.put(6, ZTE_UPF_5G_FiledName);
        sheetNameMap.put(7, HW_UPF_5G_FiledName);

    }


    /**
     * 5G 导出策略
     * @param wb
     * @param dataList
     * @param commonCheckResult
     * @param configIndex
     */
    public static void export_5G(HSSFWorkbook wb, Map<String, List<Map<String, Object>>> dataList, CommonCheckResult commonCheckResult, int configIndex){

        LinkedList commonList = setCommonMap(commonCheckResult);
        String config = config_5G[configIndex];
        Integer sheetxqCommon = Integer.valueOf(config.split(",")[1]);

        for (int i = 0; i < sheetNameArray.length; i++) {
            if (i == 0){
               setCommonSheet(wb, i, commonList);
            } else {
                List<Map<String, Object>> mapList = dataList.get(sheetNameArray[i]);

                HSSFCellStyle titleStyle = wb.createCellStyle();
                Font font = wb.createFont();
                // 设置单元格样式
                setSheetStyle(titleStyle, font);
                HSSFSheet sheet=wb.createSheet();
                // 合并单元格
                setMergedRegion(sheet, sheetxqCommon);

                HSSFRow row1 = sheet.createRow(0);
                HSSFRow row2 = sheet.createRow(1);
                HSSFRow row3 = sheet.createRow(2);
                Map<Integer,HSSFRow> hssfRowMap = new HashMap<>();
                hssfRowMap.put(0,row1);
                hssfRowMap.put(1,row2);
                hssfRowMap.put(2,row3);
                for (int j = 0; j < sheetNameMap.get(sheetxqCommon).length; j++) {
                    if (sheetNameMap.get(sheetxqCommon)[j].contains(",")){
                        String[] split = sheetNameMap.get(sheetxqCommon)[j].split(",");
                        for (int k = 0; k < split.length; k++) {
                            // 取消合并单元格重复赋值
                            if ("".equals(split[k])){
                                continue;
                            }else {
                                // 匹配空白
                                if ("@".equals(split[k])){
                                    HSSFCell cell = hssfRowMap.get(k).createCell(j);
                                    cell.setCellStyle(titleStyle);
                                }else {
                                    HSSFCell cell = hssfRowMap.get(k).createCell(j);
                                    cell.setCellValue(split[k]);
                                    cell.setCellStyle(titleStyle);
                                }

                            }
                        }
                    }else {
                        HSSFCell cell = row1.createCell(j);
                        cell.setCellValue(sheetNameMap.get(sheetxqCommon)[j]);
                        cell.setCellStyle(titleStyle);
                    }
                    sheet.autoSizeColumn(j,true);
                }
                for (int j = 0; j < 10; j++) {
                    sheet.autoSizeColumn(j,true);
                }
                int rowValueSize = mapList.size();
                // 数据区是从第三行开始：
                int count = 3;
                if (rowValueSize > 0){
                    for (int j = 0; j < rowValueSize; j++) {
                        HSSFRow row = sheet.createRow(count++);
                        Map<String, Object> map = mapList.get(j);
                        Object[] keys = map.keySet().toArray();
                        int index = 0;
                        for (int k = 0; k < keys.length; k++) {
                            Object next = map.get(keys[k].toString());
                            System.out.println(next);
                            HSSFCell cell_1 = row.createCell(index++);
                            dealCell(cell_1,next);
                            sheet.autoSizeColumn(j,true);
                        }
                    }
                }
                wb.setSheetName(i,sheetNameArray[i]);
            }
        }

    }

    private static LinkedList setCommonMap(CommonCheckResult commonCheckResult) {
        LinkedList resList = new LinkedList();
        Map<String, Object> map = JSON.parseObject(JSON.toJSONString(commonCheckResult), Map.class);
        resList.add(map.get("serviceName"));
        resList.add(map.get("returnBureau"));
        resList.add(map.get("deviceType"));
        resList.add(map.get("area"));

        resList.add(map.get("company"));
        resList.add(map.get("checkItem"));
        resList.add(map.get("deviceName"));
        resList.add(map.get("newTime"));

        resList.add(map.get("vtlCount"));
        resList.add(map.get("stdCount"));
        resList.add(map.get("correctCount"));
        resList.add(map.get("moreCount"));
        resList.add(map.get("leakCount"));

        resList.add(map.get("errCount"));
        resList.add(map.get("redundantCount"));
        return resList;
    }

    private static void setMergedRegion(HSSFSheet sheet, Integer sheetxqCommon) {

        String[] arrayConfig1 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,0,3,7","2,2,3,4"};
        String[] arrayConfig2 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,0,3,5","2,2,4,5","0,0,6,8","2,2,6,7"};
        String[] arrayConfig3 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,2,3,3","0,0,4,6","2,2,4,5","0,0,9,10","0,0,12,15","0,0,16,18","2,2,16,17","0,0,19,20","0,0,21,22","0,0,23,24","0,0,25,27","0,0,29,31","0,0,32,39","0,0,40,44","0,0,45,46","0,0,47,52","0,0,53,56","0,0,57,58","0,0,59,60","0,0,61,63","0,0,64,66","0,0,67,72","2,2,69,70","2,2,71,72","0,0,73,74","0,0,75,77","0,0,78,81","2,2,51,52","2,2,49,50"};
        String[] arrayConfig4 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,2,3,3","0,0,6,8","2,2,7,8","0,0,9,11","2,2,10,11","0,0,12,14","2,2,13,14","0,0,15,17","0,0,18,20","2,2,19,20","0,0,21,22","0,0,24,25","0,0,26,28","0,0,29,31","0,0,32,35","0,0,36,38","0,0,39,41","0,0,42,44","2,2,43,44","0,0,45,47","0,0,48,52","2,2,50,51","0,0,54,55","0,0,57,60","0,0,61,62","0,0,64,70","2,2,65,67","0,0,71,75","2,2,72,73","0,0,76,77","0,0,78,79","0,0,80,81","0,0,82,84","2,2,83,84","0,0,85,86","0,0,87,89","2,2,88,89"};
        String[] arrayConfig5 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,2,3,3","0,0,5,9","0,0,11,12","0,0,13,17","0,0,18,24","2,2,19,21","0,0,25,29","2,2,26,27","0,0,30,31","0,0,32,33","0,0,34,36","2,2,35,36","0,0,37,39","0,0,41,43","0,0,44,46","0,0,47,55"};
        String[] arrayConfig6 = {"0,2,0,0","0,2,1,1","0,2,2,2","0,2,3,3","0,0,4,5","2,2,4,5","0,0,6,8","0,0,9,10","0,0,11,22","0,0,23,29","0,0,30,35","2,2,32,33","2,2,34,35","0,0,36,38","0,0,39,41","0,0,42,44","0,0,45,53","0,0,55,56","0,0,57,59","0,0,60,61","0,0,62,64","0,0,65,67","0,0,68,70","0,0,71,77","0,0,78,79","0,0,80,83"};

        switch (sheetxqCommon){
            case 1:
                setCellRangeAddress(sheet, arrayConfig1);
                break;
            case 2:
                setCellRangeAddress(sheet, arrayConfig2);
                break;
            case 3:
                setCellRangeAddress(sheet, arrayConfig3);
                break;
            case 4:
                setCellRangeAddress(sheet, arrayConfig4);
                break;
            case 5:
                setCellRangeAddress(sheet, arrayConfig5);
                break;
            case 6:
                setCellRangeAddress(sheet, arrayConfig6);
                break;
        }
    }

    private static void setCellRangeAddress(HSSFSheet sheet, String[] array) {
        for (String s:array) {
            String[] indexZu = s.split(",");
            CellRangeAddress cellRangeAddress = new CellRangeAddress(Integer.valueOf(indexZu[0]), Integer.valueOf(indexZu[1]), Integer.valueOf(indexZu[2]), Integer.valueOf(indexZu[3]));
            sheet.addMergedRegion(cellRangeAddress);
        }
    }

    public static void setCommonSheet(HSSFWorkbook wb, int index, LinkedList commonList){
        HSSFCellStyle titleStyle = wb.createCellStyle();
        Font font = wb.createFont();
        setSheetStyle(titleStyle, font);
        HSSFSheet sheet=wb.createSheet();

        HSSFRow row = sheet.createRow(0);
        for (int j = 0; j < sheetNameMap.get(0).length; j++) {
            HSSFCell cell_1 = row.createCell(j);
            cell_1.setCellValue(sheetNameMap.get(0)[j]);
            cell_1.setCellStyle(titleStyle);
            sheet.autoSizeColumn(j,true);
        }
        HSSFRow rows = sheet.createRow(1);
        for (int j = 0; j < sheetNameMap.get(0).length; j++) {
            HSSFCell cell_1 = rows.createCell(j);
            dealCell(cell_1,commonList.get(j));

            sheet.autoSizeColumn(j,true);
        }
        wb.setSheetName(index,sheetNameArray[index]);
    }

    private static void dealCell(HSSFCell cell_1, Object o) {
        if (o instanceof String){
            cell_1.setCellValue((String) o);
            return;
        }
        if (o instanceof Boolean){
            cell_1.setCellValue((Boolean) o);
            return;
        }
        if (o instanceof Integer){
            cell_1.setCellValue((Integer) o);
            return;
        }
        if (o instanceof Date){
            cell_1.setCellValue((Date) o);
            return;
        }
        if (o instanceof Double){
            cell_1.setCellValue((Double) o);
            return;
        }
    }

    public static void setSheetStyle(HSSFCellStyle style, Font font){
        //单元格背景色
        style.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.getIndex());
        //单元格填充效果
//        style.setFillPattern(CellStyle.ALIGN_FILL);
//        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
//        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
//        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
//        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
//        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        style.setAlignment(HorizontalAlignment.CENTER);	//左右居中
        style.setVerticalAlignment(VerticalAlignment.CENTER);	//上下居中
        style.setBorderBottom(BorderStyle.MEDIUM);
        style.setBorderLeft(BorderStyle.MEDIUM);
        style.setBorderRight(BorderStyle.MEDIUM);
        style.setBorderTop(BorderStyle.MEDIUM);
        font.setFontHeightInPoints((short) 13);
        font.setFontName("仿宋_GB2312");
        style.setFont(font);//增加字体样式
    }
}
